import { Component, OnInit } from '@angular/core';
import { ApisService } from '../../apis.service';
import { Router } from '@angular/router';

@Component({
  selector: 'app-header',
  templateUrl: './header.component.html',
  styleUrls: ['./header.component.css'],
  inputs:["currentNav","cid"]
})
export class HeaderComponent implements OnInit {
  currentNav:string="";
  cid:number=0;
  cats:any[]=[];
  collapsed:boolean=true;
  query:string="";
  constructor(private apiService:ApisService,private route : Router) { }
  ToggleMenu(){
    this.collapsed=!this.collapsed;
  }
  search(){
    if(this.query.trim()===""){
      return;
    }
    if(this.currentNav=="super")
    {
      this
      .route
      .navigateByUrl("/super/" + this.query);
    }else
    {
    this
      .route
      .navigateByUrl("/search/" + this.query);
    }
  }
  ngOnInit() {
    this.apiService.category().then(result=>{
      this.cats=result.item_cats;
    });

  }

}
